Skip to content

Conversation

@libgerber
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Libby, you hit the learning goals here. Well done.

Comment on lines +14 to +16
# Time Complexity: O(log n)
# Space Complexity: O(1)
def add_helper(self, current, key, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Since this is recursive the space complexity is O(log n) assuming the tree is balanced and O(n) otherwise.

Comment on lines +31 to 33
# Time Complexity: O(log n)
# Space Complexity: O(1)
def find(self, key):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +43 to +46
# Time Complexity: O(n)
# Space Complexity: O(1)

# Time Complexity:
# Space Complexity:
def inorder_helper(self, current, values_list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , but since you're building a list of node values, the space complexity is O(n)

Comment on lines +61 to +64
# Time Complexity: O(n)
# Space Complexity: O(1)

def preorder_helper(self, current_node, values_list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Same issue with space complexity

Comment on lines +78 to +80
# Time Complexity: O(n)
# Space Complexity: O(1)
def postorder_helper(self, current_node, values_list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Same issue with space complexity

Comment on lines +95 to +97
# Time Complexity: O(n)
# Space Complexity: O(n)
def height_helper(self, current_node):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 If the tree is balanced this is O(log n) for space complexity and O(n) otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants